NotificationCS.getNotification().bind({
	f: function(t) { }
});
function getMaxZIndex(elem) {
	return 100000;
	
	var inc = 1000;
	var elems = $$("*");
	var val = inc;
	var exists = true;
	while (exists) {
		exists = false;
		for (var i = 0; i < elems.length; i++) {
			var zindex = $(elems[i]).getStyle("z-index");
			if (zindex && zindex > val && elems[i] != elem) {
				exists = true;
				break;
			}
		}
		if (exists) {
			if (val == 100000) {
				exists = false;
			}
			else {
				val += inc;
			}
		}
	}
	return val;
}

function getNotificationOverlay() {
	var Tools = ToolsPrototypeJS;
	var overlay = Tools.$first(".notification");
	if (!overlay) {
		overlay = document.createElement("div");
		overlay.className = "freebox-link-extension-chrome notification";
		Tools.$first("body").appendChild(overlay);
	}
	var maxZIndex = getMaxZIndex(overlay);
	$(overlay).setStyle({zIndex: maxZIndex});
	return overlay;
}
function showPasswordNotification() {

	var Tools = ToolsPrototypeJS;

	var url = chrome.extension.getURL("app/pages/notifications/password.html");
	Tools.ajax({
		url: url,
		success: function(data) {
			var div = document.createElement("div");
			div.innerHTML = data;
			console.log('Inserting notification password');
			console.log(div);
			getNotificationOverlay().appendChild(div);
		}
	});
	
}